<div class="page-header">
	<h1><?php  echo translate_word_shop('products_reports',$dictionary_app); ?></h1>
</div>
<div class='moust_saled_product'>
	<div class='row-fluid'>
		<div class='span4'>
			<p class='lead'><?php  echo translate_word_shop('products_sales_text',$dictionary_app); ?></p>
		</div>
		<div class='span8'>
			<div id='msp_chart'>
			</div>
			<?php 
				$prods=$shopObj ->fetch_result("SELECT product_id,SUM(quantity) FROM order_items  GROUP BY product_id ORDER BY SUM(quantity) limit 5");
				$data='';
				$values=array();
				$values[0][0]='Products';
				$values[0][1]='Number';
				$i=0;
				foreach ($prods as $key => $value) {
					$name = $shopObj->fetch_one("SELECT name FROM products_details WHERE product_id='{$value['product_id']}' AND language_id='{$language[0]['id']}'");


					$data[$i]['id']=$value['product_id'];
					$data[$i]['value']=$value[1]; 
					$data[$i]['name']= $name['name'];

					$i++;
					$values[$i][0]=$name['name'];
					$values[$i][1]= $value[1];
				}
				// $values = "['Products','Number'],";
				// foreach($data as $key=>$value){
				// 	$values.="['{$value['name']}',{$value['value']}],";
				// }

						

				
						
			?>
			<input type='hidden' id='msp_chart_value' value='<?php echo json_encode($values); ?>'>
		</div>
	</div>
</div>
<div class='moust_wanted_product'>
	<div class='row-fluid'>
		<div class='span4'>
			<p class='lead'><?php  echo translate_word_shop('products_wishmeter_text',$dictionary_app); ?></p>
		</div>
		<div class='span8'>
			<div id='msw_chart'>
			</div>
			<?php 
				$prods=$shopObj ->fetch_result("SELECT product_id,SUM(wishmeter) FROM clients_wishlists  GROUP BY product_id ORDER BY SUM(wishmeter) limit 5");
				$data='';
				$values=array();
				$values[0][0]='Products';
				$values[0][1]='Number';
				$i=0;
				foreach ($prods as $key => $value) {
					$name = $shopObj->fetch_one("SELECT name FROM products_details WHERE product_id='{$value['product_id']}' AND language_id='{$language[0]['id']}'");

							
					$data[$i]['id']=$value['product_id'];
					$data[$i]['value']=$value[1]; 
					$data[$i]['name']= $name['name'];

					$i++;
					$values[$i][0]=$name['name'];
					$values[$i][1]= $value[1];
				}		
							
			?>
			<input type='hidden' id='mwp_chart_value' value='<?php echo json_encode($values); ?>'>
		</div>
	</div>
</div>
<div class='moust_leked_product'>
	<div class='row-fluid'>
		<div class='span4'>
			<p class='lead'><?php  echo translate_word_shop('products_liked_text',$dictionary_app); ?></p>
		</div>
		<div class='span8'>
			<div id='mlp_chart'>
			</div>
			<?php 
				$prods=$shopObj ->fetch_result("SELECT id,rating FROM products ORDER BY rating limit 5");
				$data='';
				$values=array();
				$values[0][0]='Products';
				$values[0][1]='Number';
				$i=0;
				foreach ($prods as $key => $value) {
					$name = $shopObj->fetch_one("SELECT name FROM products_details WHERE product_id='{$value['id']}' AND language_id='{$language[0]['id']}'");


					$data[$i]['id']=$value['id'];
					$data[$i]['value']=$value['rating']; 
					$data[$i]['name']= $name['name'];

					$i++;
					$values[$i][0]=$name['name'];
					$values[$i][1]= $value[1];
				}			
			?>
			<input type='hidden' id='mlp_chart_value' value='<?php echo json_encode($values); ?>'>
		</div>
	</div>
</div>
<div class="page-header">
	<h1><?php  echo translate_word_shop('clients_reports',$dictionary_app); ?></h1>
</div>
<div class='moust_loyal_customers'>
	<div class='row-fluid'>
		<div class='span4'>
			<p class='lead'><?php  echo translate_word_shop('moust_loyal_customers',$dictionary_app); ?></p>
		</div>
		<div class='span8'>
			<div id='clients_chart'>
			</div>
			<?php 
				$prods=$shopObj ->fetch_result("SELECT COUNT(id),client_id FROM orders GROUP BY client_id ORDER BY COUNT(id) limit 5");
				$data='';
				$values=array();
				$values[0][0]='Clients';
				$values[0][1]='Orders';
				$i=0;
				foreach ($prods as $key => $value) {
					$name = $shopObj->fetch_one("SELECT name FROM clients  WHERE id='{$value['client_id']}'");


					$data[$i]['id']=$value['id'];
					$data[$i]['value']=$value['rating']; 
					$data[$i]['name']= $name['name'];

					$i++;
					$values[$i][0]=$name['name'];
					$values[$i][1]= $value[0];
				}			
			?>
			<input type='hidden' id='clients_chart_value' value='<?php echo json_encode($values); ?>'>
		</div>
	</div>
</div>

<div class='money_loyal_customers'>
	<div class='row-fluid'>
		<div class='span4'>
			<p class='lead'><?php  echo translate_word_shop('money_loyal_customers',$dictionary_app); ?></p>
		</div>
		<div class='span8'>
			<div id='clients_money_chart'>
			</div>
			<?php 
				$prods=$shopObj ->fetch_result("SELECT SUM(order_items.price), orders.client_id FROM orders 
												JOIN order_items ON order_items.order_id = orders.id
												GROUP BY orders.client_id ORDER BY SUM(order_items.price) limit 5");
				$data='';
				$values=array();
				$values[0][0]='Clients';
				$values[0][1]='Orders';
				$i=0;
				foreach ($prods as $key => $value) {
					$name = $shopObj->fetch_one("SELECT name FROM clients  WHERE id='{$value['client_id']}'");


					$data[$i]['id']=$value['id'];
					$data[$i]['value']=$value[0]; 
					$data[$i]['name']= $name['name'];

					$i++;
					$values[$i][0]=$name['name'];
					$values[$i][1]= $value[0];
				}			
			?>
			<input type='hidden' id='clients_money_chart_value' value='<?php echo json_encode($values); ?>'>
		</div>
	</div>
</div>
<!-- <div class="page-header">
	<h1><?php  //echo translate_word_shop('order_reports',$dictionary_app); ?></h1>
</div>
<div class='order_month'>
	<div class='row-fluid'>
		<div class='span4'>
			<p class='lead'><?php  //echo translate_word_shop('order_month',$dictionary_app); ?></p>
		</div>
		<div class='span8'>
			<div id='clients_money_chart'>
			</div> -->
			<?php 
				// $prods=$shopObj ->fetch_result("SELECT SUM(order_items.price), orders.client_id FROM orders 
				// 								JOIN order_items ON order_items.order_id = orders.id
				// 								GROUP BY orders.client_id ORDER BY SUM(order_items.price) limit 5");
				// $data='';
				// $values=array();
				// $values[0][0]='Clients';
				// $values[0][1]='Orders';
				// $i=0;
				// foreach ($prods as $key => $value) {
				// 	$name = $shopObj->fetch_one("SELECT name FROM clients  WHERE id='{$value['client_id']}'");


				// 	$data[$i]['id']=$value['id'];
				// 	$data[$i]['value']=$value[0]; 
				// 	$data[$i]['name']= $name['name'];

				// 	$i++;
				// 	$values[$i][0]=$name['name'];
				// 	$values[$i][1]= $value[0];
				// }			
			?>
	<!-- 		<input type='hidden' id='clients_money_chart_value' value='<?php //echo json_encode($values); ?>'>
		</div>
	</div>
</div> -->